<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="用户信息 | 网络下单系统 | ${clieUser.clie.estName}" />
<%@ include file="../inc/OnlineTitle.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<script src="/js/popup_ext.js"></script>
<script language="javascript">
	function doSave(){
		document.getElementById("buttonDiv").style.display="none";
		document.getElementById("waitDiv").style.display="";
		frm.submit();
	}
	function elementOnChnage(){
		checkContactChange(this.getAttribute("index"));
	}
	
	var navArr=checkNavigator();
	function doContactAdd(){
		var tbl=document.getElementById("contactRowTbl");
		var contactNum=document.getElementById("contact_num").value-0;

		var tr=document.createElement("tr");
		tr.setAttribute("id","contactTr"+contactNum);
		
		var td;
		var input;

		td=document.createElement("td");
		input=document.createElement("input");
		input.setAttribute("type","text");
		input.style.width="48px";
		input.setAttribute("maxLength","15");
		input.setAttribute("index",contactNum);
		input.setAttribute("name","contact_name_"+contactNum);
		input.setAttribute("id","contact_name_"+contactNum);
		input.setAttribute("value","");
		input.setAttribute("className","TextBox");
		input.setAttribute("class","TextBox");
		input.onchange=elementOnChnage;
		td.appendChild(input);
		tr.appendChild(td);
		
		td=document.createElement("td");
		input=document.createElement("select");
		input.setAttribute("index",contactNum);
		input.setAttribute("name","sex_"+contactNum);
		input.setAttribute("id","sex_"+contactNum);
		input.onchange=elementOnChnage;
		var opt1=document.createElement("option");
		opt1.setAttribute("value","男");
		if(navArr[0]!="msie"){
			opt1.innerText="男";
		}else{
			opt1.text="男";
			//opt1.setAttribute("text","男");
		}
		try{
			input.add(opt1,null);
		}catch(ex){
			input.add(opt1);//ie
		}
		var opt2=document.createElement("option");
		opt2.setAttribute("value","女");
		if(navArr[0]!="msie"){
			opt2.innerText="女";
		}else{
			opt2.text="女";
			//opt2.setAttribute("text","女");
		}
		try{
			input.add(opt2,null);
		}catch(ex){
			input.add(opt2);//ie
		}
		td.appendChild(input);
		tr.appendChild(td);
		
		td=document.createElement("td");
		input=document.createElement("input");
		input.setAttribute("type","text");
		input.style.width="48px";
		input.setAttribute("maxLength","15");
		input.setAttribute("index",contactNum);
		input.setAttribute("name","possie_"+contactNum);
		input.setAttribute("id","possie_"+contactNum);
		input.setAttribute("value","");
		input.setAttribute("className","TextBox");
		input.setAttribute("class","TextBox");
		input.onchange=elementOnChnage;
		td.appendChild(input);
		tr.appendChild(td);
		
		td=document.createElement("td");
		input=document.createElement("input");
		input.setAttribute("type","text");
		input.style.width="82px";
		input.setAttribute("maxLength","15");
		input.setAttribute("index",contactNum);
		input.setAttribute("name","mobile_"+contactNum);
		input.setAttribute("id","mobile_"+contactNum);
		input.setAttribute("value","");
		input.setAttribute("className","TextBox");
		input.setAttribute("class","TextBox");
		input.onchange=elementOnChnage;
		td.appendChild(input);
		tr.appendChild(td);
		
		td=document.createElement("td");
		input=document.createElement("input");
		input.setAttribute("type","text");
		input.style.width="114px";
		input.setAttribute("maxLength","50");
		input.setAttribute("index",contactNum);
		input.setAttribute("name","email_"+contactNum);
		input.setAttribute("id","email_"+contactNum);
		input.setAttribute("value","");
		input.setAttribute("className","TextBox");
		input.setAttribute("class","TextBox");
		input.onchange=elementOnChnage;
		td.appendChild(input);
		tr.appendChild(td);
		
		td=document.createElement("td");
		input=document.createElement("input");
		input.setAttribute("type","text");
		input.style.width="80px";
		input.setAttribute("maxLength","18");//NND,ie的setAttribute竟然对maxLength有区分大小写,晕倒
		input.setAttribute("index",contactNum);
		input.setAttribute("name","phone_"+contactNum);
		input.setAttribute("id","phone_"+contactNum);
		input.setAttribute("value","");
		input.setAttribute("className","TextBox");
		input.setAttribute("class","TextBox");
		input.onchange=elementOnChnage;
		td.appendChild(input);
		tr.appendChild(td);
		
		td=document.createElement("td");
		input=document.createElement("input");
		input.setAttribute("type","text");
		input.style.width="80px";
		input.setAttribute("maxLength","25");
		input.setAttribute("index",contactNum);
		input.setAttribute("name","im_"+contactNum);
		input.setAttribute("id","im_"+contactNum);
		input.setAttribute("value","");
		input.setAttribute("className","TextBox");
		input.setAttribute("class","TextBox");
		input.onchange=elementOnChnage;
		td.appendChild(input);
		tr.appendChild(td);
		
		td=document.createElement("td");
		input=document.createElement("input");
		input.setAttribute("type","text");
		input.style.width="80px";
		input.setAttribute("maxLength","100");
		input.setAttribute("index",contactNum);
		input.setAttribute("name","mark_"+contactNum);
		input.setAttribute("id","mark_"+contactNum);
		input.setAttribute("value","");
		input.setAttribute("className","TextBox");
		input.setAttribute("class","TextBox");
		input.onchange=elementOnChnage;
		td.appendChild(input);
		tr.appendChild(td);
		
		td=document.createElement("td");
		input=document.createElement("input");
		input.setAttribute("type","checkbox");
		input.setAttribute("index",contactNum);
		input.setAttribute("name","is_main_"+contactNum);
		input.setAttribute("id","is_main_"+contactNum);
		input.setAttribute("value","1");
		input.onchange=elementOnChnage;
		td.appendChild(input);
		tr.appendChild(td);
		
		td=document.createElement("td");
		var link=document.createElement("a");
		link.setAttribute("href","javascript:doContactDelete("+contactNum+");");
		link.appendChild(document.createTextNode("删除"));
		td.appendChild(link);
		input=document.createElement("input");
		input.setAttribute("type","hidden");
		input.setAttribute("name","status_"+contactNum);
		input.setAttribute("id","status_"+contactNum);
		input.setAttribute("value","UNCHANGE");
		td.appendChild(input);
		input=document.createElement("input");
		input.setAttribute("type","hidden");
		input.setAttribute("name","id_"+contactNum);
		input.setAttribute("id","id_"+contactNum);
		input.setAttribute("value","0");
		td.appendChild(input);
		tr.appendChild(td);

		tbl.appendChild(tr);
		document.getElementById("contact_num").value=contactNum+1;
		
		resizePopwin();
	}
	function doContactDelete(index){
		ShowConfirm('确认框','确定删除吗？',340,80,"doContactDeleteAct("+index+")");
	}
	function doContactDeleteAct(index){
		if(popRetVal!=null){
			document.getElementById("contactTr"+index).style.display="none";
			document.getElementById("status_"+index).value="DELETE";
			
			resizePopwin();
		}
	}
	function doInit(){
		showFormErrorMsg();
		resizePopwin();
	}
	function checkContactChange(index){
		if(document.getElementById("id_"+index).value=="" || document.getElementById("id_"+index).value=="0"){
			document.getElementById("status_"+index).value="NEW";
		}else{
			document.getElementById("status_"+index).value="EDIT";
		}
	}
</script>
</head>
<body onload="doInit();" class="sheet modal-dialog" style="padding-top:10px;text-align:center;" >
<div class="sheet-main" id="bodyDiv" style="width:940px;margin:auto;text-align:left;">
<form name="frm" method="post"> 
  <div class="sheet-list" style="width:100%">
    <div class="modal-main search-business">
    	<div style="width:100%;">
    		<c:set var="pageTopTitle" value="用户信息" />
			<%@ include file="../inc/PageTop.jsp"%>
			
			<div class="blank12"></div> 
    		<table border="0" cellspacing="1" cellpadding="1" align="center" class="table-0">
				<tr>
			      	<th style="width:9%">单位名称：</th>
			      	<td>${command.establishment.estName}</td>
			    </tr>
			</table>
			
			<div class="blank12"></div>
			<fieldset class="det_fieldset "> <legend class="mag10">联系信息</legend>
	    	<table border="0" cellspacing="1" cellpadding="1" align="center" class="table-a2">
				<tr>
			      	<th>电话：</th>
			     	<spring:bind path="command.establishment.phone">
			     	<td>
			     		<input type="text" class="TextBox readonly" readonly="true" id="${status.expression}" name="${status.expression}" value="${status.value}">
				        <script language="javascript">
				          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',1,'establishment.phone');
				        </script>
			     	</td>
			     	</spring:bind>
			      	<th>传真：</th>
			     	<spring:bind path="command.establishment.fax">
			     	<td>
			     		<input type="text" class="TextBox" maxlength="20" onKeyUp="goNextInput('establishment.email');" id="${status.expression}" name="${status.expression}" value="${status.value}">
				        <script language="javascript">
				          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',2,'establishment.fax');
				        </script>
			     	</td>
			     	</spring:bind>
			     	<th>Email：</th>
			     	<spring:bind path="command.establishment.email">
			     	<td>
			     		<input type="text" class="TextBox" maxlength="50" onKeyUp="goNextInput('establishment.webSite');" id="${status.expression}" name="${status.expression}" value="${status.value}">
				        <script language="javascript">
				          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',3,'establishment.email');
				        </script>
			     	</td>
			     	</spring:bind>
			    </tr>
			    <tr>
			      	<th>网站地址：</th>
			     	<spring:bind path="command.establishment.webSite">
			     	<td>
			     		<input type="text" class="TextBox" maxlength="50" onKeyUp="goNextInput('establishment.postcode');" id="${status.expression}" name="${status.expression}" value="${status.value}">
				        <script language="javascript">
				          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',4,'establishment.webSite');
				        </script>
			     	</td>
			     	</spring:bind>
			      	<th>地区：</th>
			     	<spring:bind path="command.establishment.areaId">
			     	<td>
			  			<select id="${status.expression}" name="${status.expression}" style="width:140px">
							<option value="0">==请选择==</option>
							<commonTag:createSelectTree list="${areaList}" emptyOption="0" justEnabled="1" defaultValue="${status.value}" />
						</select>
				        <script language="javascript">
				          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',5,'establishment.areaId');
				        </script>
			     	</td>
			     	</spring:bind>
			     	<th>邮编：</th>
			     	<spring:bind path="command.establishment.postcode">
			     	<td>
			     		<input type="text"  class="TextBox"  maxlength="10" onKeyUp="goNextInput('establishment.address');" id="${status.expression}" name="${status.expression}" value="${status.value}">
				        <script language="javascript">
				          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',6,'establishment.postcode');
				        </script>
			     	</td>
			     	</spring:bind>
			    </tr>
			    <tr >
			      	<th><span class="MustInput">*</span>地址：</th>
			     	<spring:bind path="command.establishment.address">
			     	<td colspan="5">
			     		<input type="text" class="TextBox" maxlength="50" style="width:390px" id="${status.expression}" name="${status.expression}" value="${status.value}">
				        <script language="javascript">
				          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',7,'establishment.address');
				        </script>
			     	</td>
			     	</spring:bind>
			    </tr>
									
			</table>
			</fieldset>
			
		  	<div class="blank12"></div>
		  	<fieldset class="det_fieldset">
		  	<legend class="mag10">联系人</legend>				  
			<div class="table-list" style="padding:10px">
		  	  	<input type="hidden" name="contact_num" id="contact_num" value="${fn:length(command.contacts)}">
				<table width="100%" border="0" cellspacing="1" cellpadding="1" align="center" id="contactTbl">
					<tbody id="contactRowTbl">
					<tr >
						<th  width="8%">姓名</th>
						<th  width="6%">性别</th>
						<th  width="8%">职务</th>
						<th  width="13%">手机</th>
						<th  width="16%">Email</th>
						<th  width="13%">电话</th>
						<th  width="13%">QQ</th>
						<th  width="13%">备注</th>
						<th  width="5%">主要</th>
						<th  width="5%">操作</th>
					</tr>
					<c:forEach var="item" items="${command.contacts}" varStatus="i">
					<tr id="contactTr${i.index}" <c:if test="${item.status=='DELETE'}">style="display:none"</c:if>>
						<td >
							<input type="text" style="width:48px" class="TextBox"  maxlength="15" id="contact_name_${i.index}" name="contact_name_${i.index}" value="${item.establishmentContact.contactName}" onChange="checkContactChange(${i.index});">
						</td>
						<td >
							<select id="sex_${i.index}" name="sex_${i.index}" onChange="checkContactChange(${i.index});">
							   <option value="男" <c:if test="${item.establishmentContact.sex=='男'}">selected</c:if>>男</option>
							   <option value="女" <c:if test="${item.establishmentContact.sex=='女'}">selected</c:if>>女</option>
							</select>
						</td>
						<td >
							<input type="text" style="width:48px" class="TextBox"  maxlength="15" id="possie_${i.index}" name="possie_${i.index}" value="${item.establishmentContact.possie}" onChange="checkContactChange(${i.index});">
						</td>
						<td >
							<input type="text" style="width:82px" class="TextBox"  maxlength="15" id="mobile_${i.index}" name="mobile_${i.index}" value="${item.establishmentContact.mobile}" onChange="checkContactChange(${i.index});">
						</td>
						<td >
							<input type="text" style="width:114px" class="TextBox"  maxlength="50" id="email_${i.index}" name="email_${i.index}" value="${item.establishmentContact.email}" onChange="checkContactChange(${i.index});">
						</td>
						<td >
							<input type="text" style="width:80px" class="TextBox"  maxlength="18" id="phone_${i.index}" name="phone_${i.index}" value="${item.establishmentContact.phone}" onChange="checkContactChange(${i.index});">
						</td>
						<td >
							<input type="text" style="width:80px" class="TextBox"  maxlength="25" id="im_${i.index}" name="im_${i.index}" value="${item.establishmentContact.im}" onChange="checkContactChange(${i.index});">
						</td>
						<td >
							<input type="text" style="width:80px" class="TextBox"  maxlength="100" id="mark_${i.index}" name="mark_${i.index}" value="${item.establishmentContact.mark}" onChange="checkContactChange(${i.index});">
						</td>
						<td >
							<input type="checkbox" id="is_main_${i.index}" name="is_main_${i.index}" value="1" <c:if test="${item.establishmentContact.isMain=='Y'}">checked</c:if> onChange="checkContactChange(${i.index});">
						</td>
						<td >
							<a href="javascript:doContactDelete(${i.index});">删除</a>
							<input type="hidden" id="status_${i.index}" name="status_${i.index}" value="${item.status}">
							<input type="hidden" id="id_${i.index}" name="id_${i.index}" value="${item.oldId}">
						</td>
					</tr>
					</c:forEach>
					</tbody>
				</table>
				<div class="table-bot">
				  <a href="javascript:doContactAdd();">增加一行</a>
			  	</div>
				<spring:bind path="command.contacts">
		          <script language="javascript">
		          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',8);
		        	</script>
				</spring:bind>				  	
			</div>
			</fieldset>
				  
		</div>
	  </div>
  	</div>
  	
	<div class="modal-buttom" id="buttonDiv">
		<input type="button" class="buttom-a" value=" 提交修改 " onClick="doSave();">
	</div>	
	<div class="modal-buttom" id="waitDiv" style="display:none">
		<span style="color:#ffffff">请稍候...</span>
	</div>
</form>
</div>
</body>
</html>
